#include "live.h"

namespace {
#define DIM 22
#define EDIM 21
#define MEDIM 21
typedef void (*Hfun)(double *, double *, double *);
const static double MAHA_THRESH_4 = 7.814727903251177;
const static double MAHA_THRESH_9 = 7.814727903251177;
const static double MAHA_THRESH_10 = 7.814727903251177;
const static double MAHA_THRESH_12 = 7.814727903251177;
const static double MAHA_THRESH_35 = 7.814727903251177;
const static double MAHA_THRESH_32 = 9.487729036781154;
const static double MAHA_THRESH_13 = 7.814727903251177;
const static double MAHA_THRESH_14 = 7.814727903251177;
const static double MAHA_THRESH_33 = 7.814727903251177;

/******************************************************************************
 *                       Code generated with sympy 1.9                        *
 *                                                                            *
 *              See http://www.sympy.org/ for more information.               *
 *                                                                            *
 *                         This file is part of 'ekf'                         *
 ******************************************************************************/
void H(double *in_vec, double *out_7310749464307319056) {
   out_7310749464307319056[0] = 0;
   out_7310749464307319056[1] = -sin(in_vec[1])*sin(in_vec[2])*in_vec[4] - sin(in_vec[1])*cos(in_vec[2])*in_vec[3] - cos(in_vec[1])*in_vec[5];
   out_7310749464307319056[2] = -sin(in_vec[2])*cos(in_vec[1])*in_vec[3] + cos(in_vec[1])*cos(in_vec[2])*in_vec[4];
   out_7310749464307319056[3] = cos(in_vec[1])*cos(in_vec[2]);
   out_7310749464307319056[4] = sin(in_vec[2])*cos(in_vec[1]);
   out_7310749464307319056[5] = -sin(in_vec[1]);
   out_7310749464307319056[6] = (sin(in_vec[0])*sin(in_vec[2]) + sin(in_vec[1])*cos(in_vec[0])*cos(in_vec[2]))*in_vec[3] + (-sin(in_vec[0])*cos(in_vec[2]) + sin(in_vec[1])*sin(in_vec[2])*cos(in_vec[0]))*in_vec[4] + cos(in_vec[0])*cos(in_vec[1])*in_vec[5];
   out_7310749464307319056[7] = -sin(in_vec[0])*sin(in_vec[1])*in_vec[5] + sin(in_vec[0])*sin(in_vec[2])*cos(in_vec[1])*in_vec[4] + sin(in_vec[0])*cos(in_vec[1])*cos(in_vec[2])*in_vec[3];
   out_7310749464307319056[8] = (-sin(in_vec[0])*sin(in_vec[1])*sin(in_vec[2]) - cos(in_vec[0])*cos(in_vec[2]))*in_vec[3] + (sin(in_vec[0])*sin(in_vec[1])*cos(in_vec[2]) - sin(in_vec[2])*cos(in_vec[0]))*in_vec[4];
   out_7310749464307319056[9] = sin(in_vec[0])*sin(in_vec[1])*cos(in_vec[2]) - sin(in_vec[2])*cos(in_vec[0]);
   out_7310749464307319056[10] = sin(in_vec[0])*sin(in_vec[1])*sin(in_vec[2]) + cos(in_vec[0])*cos(in_vec[2]);
   out_7310749464307319056[11] = sin(in_vec[0])*cos(in_vec[1]);
   out_7310749464307319056[12] = (-sin(in_vec[0])*sin(in_vec[1])*sin(in_vec[2]) - cos(in_vec[0])*cos(in_vec[2]))*in_vec[4] + (-sin(in_vec[0])*sin(in_vec[1])*cos(in_vec[2]) + sin(in_vec[2])*cos(in_vec[0]))*in_vec[3] - sin(in_vec[0])*cos(in_vec[1])*in_vec[5];
   out_7310749464307319056[13] = -sin(in_vec[1])*cos(in_vec[0])*in_vec[5] + sin(in_vec[2])*cos(in_vec[0])*cos(in_vec[1])*in_vec[4] + cos(in_vec[0])*cos(in_vec[1])*cos(in_vec[2])*in_vec[3];
   out_7310749464307319056[14] = (sin(in_vec[0])*sin(in_vec[2]) + sin(in_vec[1])*cos(in_vec[0])*cos(in_vec[2]))*in_vec[4] + (sin(in_vec[0])*cos(in_vec[2]) - sin(in_vec[1])*sin(in_vec[2])*cos(in_vec[0]))*in_vec[3];
   out_7310749464307319056[15] = sin(in_vec[0])*sin(in_vec[2]) + sin(in_vec[1])*cos(in_vec[0])*cos(in_vec[2]);
   out_7310749464307319056[16] = -sin(in_vec[0])*cos(in_vec[2]) + sin(in_vec[1])*sin(in_vec[2])*cos(in_vec[0]);
   out_7310749464307319056[17] = cos(in_vec[0])*cos(in_vec[1]);
}
void err_fun(double *nom_x, double *delta_x, double *out_8236526131657428764) {
   out_8236526131657428764[0] = delta_x[0] + nom_x[0];
   out_8236526131657428764[1] = delta_x[1] + nom_x[1];
   out_8236526131657428764[2] = delta_x[2] + nom_x[2];
   out_8236526131657428764[3] = -0.5*delta_x[3]*nom_x[4] - 0.5*delta_x[4]*nom_x[5] - 0.5*delta_x[5]*nom_x[6] + 1.0*nom_x[3];
   out_8236526131657428764[4] = 0.5*delta_x[3]*nom_x[3] + 0.5*delta_x[4]*nom_x[6] - 0.5*delta_x[5]*nom_x[5] + 1.0*nom_x[4];
   out_8236526131657428764[5] = -0.5*delta_x[3]*nom_x[6] + 0.5*delta_x[4]*nom_x[3] + 0.5*delta_x[5]*nom_x[4] + 1.0*nom_x[5];
   out_8236526131657428764[6] = 0.5*delta_x[3]*nom_x[5] - 0.5*delta_x[4]*nom_x[4] + 0.5*delta_x[5]*nom_x[3] + 1.0*nom_x[6];
   out_8236526131657428764[7] = delta_x[6] + nom_x[7];
   out_8236526131657428764[8] = delta_x[7] + nom_x[8];
   out_8236526131657428764[9] = delta_x[8] + nom_x[9];
   out_8236526131657428764[10] = delta_x[9] + nom_x[10];
   out_8236526131657428764[11] = delta_x[10] + nom_x[11];
   out_8236526131657428764[12] = delta_x[11] + nom_x[12];
   out_8236526131657428764[13] = delta_x[12] + nom_x[13];
   out_8236526131657428764[14] = delta_x[13] + nom_x[14];
   out_8236526131657428764[15] = delta_x[14] + nom_x[15];
   out_8236526131657428764[16] = delta_x[15] + nom_x[16];
   out_8236526131657428764[17] = delta_x[16] + nom_x[17];
   out_8236526131657428764[18] = delta_x[17] + nom_x[18];
   out_8236526131657428764[19] = delta_x[18] + nom_x[19];
   out_8236526131657428764[20] = delta_x[19] + nom_x[20];
   out_8236526131657428764[21] = delta_x[20] + nom_x[21];
}
void inv_err_fun(double *nom_x, double *true_x, double *out_4747477926419252764) {
   out_4747477926419252764[0] = -nom_x[0] + true_x[0];
   out_4747477926419252764[1] = -nom_x[1] + true_x[1];
   out_4747477926419252764[2] = -nom_x[2] + true_x[2];
   out_4747477926419252764[3] = 2*nom_x[3]*true_x[4] - 2*nom_x[4]*true_x[3] + 2*nom_x[5]*true_x[6] - 2*nom_x[6]*true_x[5];
   out_4747477926419252764[4] = 2*nom_x[3]*true_x[5] - 2*nom_x[4]*true_x[6] - 2*nom_x[5]*true_x[3] + 2*nom_x[6]*true_x[4];
   out_4747477926419252764[5] = 2*nom_x[3]*true_x[6] + 2*nom_x[4]*true_x[5] - 2*nom_x[5]*true_x[4] - 2*nom_x[6]*true_x[3];
   out_4747477926419252764[6] = -nom_x[7] + true_x[7];
   out_4747477926419252764[7] = -nom_x[8] + true_x[8];
   out_4747477926419252764[8] = -nom_x[9] + true_x[9];
   out_4747477926419252764[9] = -nom_x[10] + true_x[10];
   out_4747477926419252764[10] = -nom_x[11] + true_x[11];
   out_4747477926419252764[11] = -nom_x[12] + true_x[12];
   out_4747477926419252764[12] = -nom_x[13] + true_x[13];
   out_4747477926419252764[13] = -nom_x[14] + true_x[14];
   out_4747477926419252764[14] = -nom_x[15] + true_x[15];
   out_4747477926419252764[15] = -nom_x[16] + true_x[16];
   out_4747477926419252764[16] = -nom_x[17] + true_x[17];
   out_4747477926419252764[17] = -nom_x[18] + true_x[18];
   out_4747477926419252764[18] = -nom_x[19] + true_x[19];
   out_4747477926419252764[19] = -nom_x[20] + true_x[20];
   out_4747477926419252764[20] = -nom_x[21] + true_x[21];
}
void H_mod_fun(double *state, double *out_341303559384211768) {
   out_341303559384211768[0] = 1.0;
   out_341303559384211768[1] = 0;
   out_341303559384211768[2] = 0;
   out_341303559384211768[3] = 0;
   out_341303559384211768[4] = 0;
   out_341303559384211768[5] = 0;
   out_341303559384211768[6] = 0;
   out_341303559384211768[7] = 0;
   out_341303559384211768[8] = 0;
   out_341303559384211768[9] = 0;
   out_341303559384211768[10] = 0;
   out_341303559384211768[11] = 0;
   out_341303559384211768[12] = 0;
   out_341303559384211768[13] = 0;
   out_341303559384211768[14] = 0;
   out_341303559384211768[15] = 0;
   out_341303559384211768[16] = 0;
   out_341303559384211768[17] = 0;
   out_341303559384211768[18] = 0;
   out_341303559384211768[19] = 0;
   out_341303559384211768[20] = 0;
   out_341303559384211768[21] = 0;
   out_341303559384211768[22] = 1.0;
   out_341303559384211768[23] = 0;
   out_341303559384211768[24] = 0;
   out_341303559384211768[25] = 0;
   out_341303559384211768[26] = 0;
   out_341303559384211768[27] = 0;
   out_341303559384211768[28] = 0;
   out_341303559384211768[29] = 0;
   out_341303559384211768[30] = 0;
   out_341303559384211768[31] = 0;
   out_341303559384211768[32] = 0;
   out_341303559384211768[33] = 0;
   out_341303559384211768[34] = 0;
   out_341303559384211768[35] = 0;
   out_341303559384211768[36] = 0;
   out_341303559384211768[37] = 0;
   out_341303559384211768[38] = 0;
   out_341303559384211768[39] = 0;
   out_341303559384211768[40] = 0;
   out_341303559384211768[41] = 0;
   out_341303559384211768[42] = 0;
   out_341303559384211768[43] = 0;
   out_341303559384211768[44] = 1.0;
   out_341303559384211768[45] = 0;
   out_341303559384211768[46] = 0;
   out_341303559384211768[47] = 0;
   out_341303559384211768[48] = 0;
   out_341303559384211768[49] = 0;
   out_341303559384211768[50] = 0;
   out_341303559384211768[51] = 0;
   out_341303559384211768[52] = 0;
   out_341303559384211768[53] = 0;
   out_341303559384211768[54] = 0;
   out_341303559384211768[55] = 0;
   out_341303559384211768[56] = 0;
   out_341303559384211768[57] = 0;
   out_341303559384211768[58] = 0;
   out_341303559384211768[59] = 0;
   out_341303559384211768[60] = 0;
   out_341303559384211768[61] = 0;
   out_341303559384211768[62] = 0;
   out_341303559384211768[63] = 0;
   out_341303559384211768[64] = 0;
   out_341303559384211768[65] = 0;
   out_341303559384211768[66] = -0.5*state[4];
   out_341303559384211768[67] = -0.5*state[5];
   out_341303559384211768[68] = -0.5*state[6];
   out_341303559384211768[69] = 0;
   out_341303559384211768[70] = 0;
   out_341303559384211768[71] = 0;
   out_341303559384211768[72] = 0;
   out_341303559384211768[73] = 0;
   out_341303559384211768[74] = 0;
   out_341303559384211768[75] = 0;
   out_341303559384211768[76] = 0;
   out_341303559384211768[77] = 0;
   out_341303559384211768[78] = 0;
   out_341303559384211768[79] = 0;
   out_341303559384211768[80] = 0;
   out_341303559384211768[81] = 0;
   out_341303559384211768[82] = 0;
   out_341303559384211768[83] = 0;
   out_341303559384211768[84] = 0;
   out_341303559384211768[85] = 0;
   out_341303559384211768[86] = 0;
   out_341303559384211768[87] = 0.5*state[3];
   out_341303559384211768[88] = 0.5*state[6];
   out_341303559384211768[89] = -0.5*state[5];
   out_341303559384211768[90] = 0;
   out_341303559384211768[91] = 0;
   out_341303559384211768[92] = 0;
   out_341303559384211768[93] = 0;
   out_341303559384211768[94] = 0;
   out_341303559384211768[95] = 0;
   out_341303559384211768[96] = 0;
   out_341303559384211768[97] = 0;
   out_341303559384211768[98] = 0;
   out_341303559384211768[99] = 0;
   out_341303559384211768[100] = 0;
   out_341303559384211768[101] = 0;
   out_341303559384211768[102] = 0;
   out_341303559384211768[103] = 0;
   out_341303559384211768[104] = 0;
   out_341303559384211768[105] = 0;
   out_341303559384211768[106] = 0;
   out_341303559384211768[107] = 0;
   out_341303559384211768[108] = -0.5*state[6];
   out_341303559384211768[109] = 0.5*state[3];
   out_341303559384211768[110] = 0.5*state[4];
   out_341303559384211768[111] = 0;
   out_341303559384211768[112] = 0;
   out_341303559384211768[113] = 0;
   out_341303559384211768[114] = 0;
   out_341303559384211768[115] = 0;
   out_341303559384211768[116] = 0;
   out_341303559384211768[117] = 0;
   out_341303559384211768[118] = 0;
   out_341303559384211768[119] = 0;
   out_341303559384211768[120] = 0;
   out_341303559384211768[121] = 0;
   out_341303559384211768[122] = 0;
   out_341303559384211768[123] = 0;
   out_341303559384211768[124] = 0;
   out_341303559384211768[125] = 0;
   out_341303559384211768[126] = 0;
   out_341303559384211768[127] = 0;
   out_341303559384211768[128] = 0;
   out_341303559384211768[129] = 0.5*state[5];
   out_341303559384211768[130] = -0.5*state[4];
   out_341303559384211768[131] = 0.5*state[3];
   out_341303559384211768[132] = 0;
   out_341303559384211768[133] = 0;
   out_341303559384211768[134] = 0;
   out_341303559384211768[135] = 0;
   out_341303559384211768[136] = 0;
   out_341303559384211768[137] = 0;
   out_341303559384211768[138] = 0;
   out_341303559384211768[139] = 0;
   out_341303559384211768[140] = 0;
   out_341303559384211768[141] = 0;
   out_341303559384211768[142] = 0;
   out_341303559384211768[143] = 0;
   out_341303559384211768[144] = 0;
   out_341303559384211768[145] = 0;
   out_341303559384211768[146] = 0;
   out_341303559384211768[147] = 0;
   out_341303559384211768[148] = 0;
   out_341303559384211768[149] = 0;
   out_341303559384211768[150] = 0;
   out_341303559384211768[151] = 0;
   out_341303559384211768[152] = 0;
   out_341303559384211768[153] = 1.0;
   out_341303559384211768[154] = 0;
   out_341303559384211768[155] = 0;
   out_341303559384211768[156] = 0;
   out_341303559384211768[157] = 0;
   out_341303559384211768[158] = 0;
   out_341303559384211768[159] = 0;
   out_341303559384211768[160] = 0;
   out_341303559384211768[161] = 0;
   out_341303559384211768[162] = 0;
   out_341303559384211768[163] = 0;
   out_341303559384211768[164] = 0;
   out_341303559384211768[165] = 0;
   out_341303559384211768[166] = 0;
   out_341303559384211768[167] = 0;
   out_341303559384211768[168] = 0;
   out_341303559384211768[169] = 0;
   out_341303559384211768[170] = 0;
   out_341303559384211768[171] = 0;
   out_341303559384211768[172] = 0;
   out_341303559384211768[173] = 0;
   out_341303559384211768[174] = 0;
   out_341303559384211768[175] = 1.0;
   out_341303559384211768[176] = 0;
   out_341303559384211768[177] = 0;
   out_341303559384211768[178] = 0;
   out_341303559384211768[179] = 0;
   out_341303559384211768[180] = 0;
   out_341303559384211768[181] = 0;
   out_341303559384211768[182] = 0;
   out_341303559384211768[183] = 0;
   out_341303559384211768[184] = 0;
   out_341303559384211768[185] = 0;
   out_341303559384211768[186] = 0;
   out_341303559384211768[187] = 0;
   out_341303559384211768[188] = 0;
   out_341303559384211768[189] = 0;
   out_341303559384211768[190] = 0;
   out_341303559384211768[191] = 0;
   out_341303559384211768[192] = 0;
   out_341303559384211768[193] = 0;
   out_341303559384211768[194] = 0;
   out_341303559384211768[195] = 0;
   out_341303559384211768[196] = 0;
   out_341303559384211768[197] = 1.0;
   out_341303559384211768[198] = 0;
   out_341303559384211768[199] = 0;
   out_341303559384211768[200] = 0;
   out_341303559384211768[201] = 0;
   out_341303559384211768[202] = 0;
   out_341303559384211768[203] = 0;
   out_341303559384211768[204] = 0;
   out_341303559384211768[205] = 0;
   out_341303559384211768[206] = 0;
   out_341303559384211768[207] = 0;
   out_341303559384211768[208] = 0;
   out_341303559384211768[209] = 0;
   out_341303559384211768[210] = 0;
   out_341303559384211768[211] = 0;
   out_341303559384211768[212] = 0;
   out_341303559384211768[213] = 0;
   out_341303559384211768[214] = 0;
   out_341303559384211768[215] = 0;
   out_341303559384211768[216] = 0;
   out_341303559384211768[217] = 0;
   out_341303559384211768[218] = 0;
   out_341303559384211768[219] = 1.0;
   out_341303559384211768[220] = 0;
   out_341303559384211768[221] = 0;
   out_341303559384211768[222] = 0;
   out_341303559384211768[223] = 0;
   out_341303559384211768[224] = 0;
   out_341303559384211768[225] = 0;
   out_341303559384211768[226] = 0;
   out_341303559384211768[227] = 0;
   out_341303559384211768[228] = 0;
   out_341303559384211768[229] = 0;
   out_341303559384211768[230] = 0;
   out_341303559384211768[231] = 0;
   out_341303559384211768[232] = 0;
   out_341303559384211768[233] = 0;
   out_341303559384211768[234] = 0;
   out_341303559384211768[235] = 0;
   out_341303559384211768[236] = 0;
   out_341303559384211768[237] = 0;
   out_341303559384211768[238] = 0;
   out_341303559384211768[239] = 0;
   out_341303559384211768[240] = 0;
   out_341303559384211768[241] = 1.0;
   out_341303559384211768[242] = 0;
   out_341303559384211768[243] = 0;
   out_341303559384211768[244] = 0;
   out_341303559384211768[245] = 0;
   out_341303559384211768[246] = 0;
   out_341303559384211768[247] = 0;
   out_341303559384211768[248] = 0;
   out_341303559384211768[249] = 0;
   out_341303559384211768[250] = 0;
   out_341303559384211768[251] = 0;
   out_341303559384211768[252] = 0;
   out_341303559384211768[253] = 0;
   out_341303559384211768[254] = 0;
   out_341303559384211768[255] = 0;
   out_341303559384211768[256] = 0;
   out_341303559384211768[257] = 0;
   out_341303559384211768[258] = 0;
   out_341303559384211768[259] = 0;
   out_341303559384211768[260] = 0;
   out_341303559384211768[261] = 0;
   out_341303559384211768[262] = 0;
   out_341303559384211768[263] = 1.0;
   out_341303559384211768[264] = 0;
   out_341303559384211768[265] = 0;
   out_341303559384211768[266] = 0;
   out_341303559384211768[267] = 0;
   out_341303559384211768[268] = 0;
   out_341303559384211768[269] = 0;
   out_341303559384211768[270] = 0;
   out_341303559384211768[271] = 0;
   out_341303559384211768[272] = 0;
   out_341303559384211768[273] = 0;
   out_341303559384211768[274] = 0;
   out_341303559384211768[275] = 0;
   out_341303559384211768[276] = 0;
   out_341303559384211768[277] = 0;
   out_341303559384211768[278] = 0;
   out_341303559384211768[279] = 0;
   out_341303559384211768[280] = 0;
   out_341303559384211768[281] = 0;
   out_341303559384211768[282] = 0;
   out_341303559384211768[283] = 0;
   out_341303559384211768[284] = 0;
   out_341303559384211768[285] = 1.0;
   out_341303559384211768[286] = 0;
   out_341303559384211768[287] = 0;
   out_341303559384211768[288] = 0;
   out_341303559384211768[289] = 0;
   out_341303559384211768[290] = 0;
   out_341303559384211768[291] = 0;
   out_341303559384211768[292] = 0;
   out_341303559384211768[293] = 0;
   out_341303559384211768[294] = 0;
   out_341303559384211768[295] = 0;
   out_341303559384211768[296] = 0;
   out_341303559384211768[297] = 0;
   out_341303559384211768[298] = 0;
   out_341303559384211768[299] = 0;
   out_341303559384211768[300] = 0;
   out_341303559384211768[301] = 0;
   out_341303559384211768[302] = 0;
   out_341303559384211768[303] = 0;
   out_341303559384211768[304] = 0;
   out_341303559384211768[305] = 0;
   out_341303559384211768[306] = 0;
   out_341303559384211768[307] = 1.0;
   out_341303559384211768[308] = 0;
   out_341303559384211768[309] = 0;
   out_341303559384211768[310] = 0;
   out_341303559384211768[311] = 0;
   out_341303559384211768[312] = 0;
   out_341303559384211768[313] = 0;
   out_341303559384211768[314] = 0;
   out_341303559384211768[315] = 0;
   out_341303559384211768[316] = 0;
   out_341303559384211768[317] = 0;
   out_341303559384211768[318] = 0;
   out_341303559384211768[319] = 0;
   out_341303559384211768[320] = 0;
   out_341303559384211768[321] = 0;
   out_341303559384211768[322] = 0;
   out_341303559384211768[323] = 0;
   out_341303559384211768[324] = 0;
   out_341303559384211768[325] = 0;
   out_341303559384211768[326] = 0;
   out_341303559384211768[327] = 0;
   out_341303559384211768[328] = 0;
   out_341303559384211768[329] = 1.0;
   out_341303559384211768[330] = 0;
   out_341303559384211768[331] = 0;
   out_341303559384211768[332] = 0;
   out_341303559384211768[333] = 0;
   out_341303559384211768[334] = 0;
   out_341303559384211768[335] = 0;
   out_341303559384211768[336] = 0;
   out_341303559384211768[337] = 0;
   out_341303559384211768[338] = 0;
   out_341303559384211768[339] = 0;
   out_341303559384211768[340] = 0;
   out_341303559384211768[341] = 0;
   out_341303559384211768[342] = 0;
   out_341303559384211768[343] = 0;
   out_341303559384211768[344] = 0;
   out_341303559384211768[345] = 0;
   out_341303559384211768[346] = 0;
   out_341303559384211768[347] = 0;
   out_341303559384211768[348] = 0;
   out_341303559384211768[349] = 0;
   out_341303559384211768[350] = 0;
   out_341303559384211768[351] = 1.0;
   out_341303559384211768[352] = 0;
   out_341303559384211768[353] = 0;
   out_341303559384211768[354] = 0;
   out_341303559384211768[355] = 0;
   out_341303559384211768[356] = 0;
   out_341303559384211768[357] = 0;
   out_341303559384211768[358] = 0;
   out_341303559384211768[359] = 0;
   out_341303559384211768[360] = 0;
   out_341303559384211768[361] = 0;
   out_341303559384211768[362] = 0;
   out_341303559384211768[363] = 0;
   out_341303559384211768[364] = 0;
   out_341303559384211768[365] = 0;
   out_341303559384211768[366] = 0;
   out_341303559384211768[367] = 0;
   out_341303559384211768[368] = 0;
   out_341303559384211768[369] = 0;
   out_341303559384211768[370] = 0;
   out_341303559384211768[371] = 0;
   out_341303559384211768[372] = 0;
   out_341303559384211768[373] = 1.0;
   out_341303559384211768[374] = 0;
   out_341303559384211768[375] = 0;
   out_341303559384211768[376] = 0;
   out_341303559384211768[377] = 0;
   out_341303559384211768[378] = 0;
   out_341303559384211768[379] = 0;
   out_341303559384211768[380] = 0;
   out_341303559384211768[381] = 0;
   out_341303559384211768[382] = 0;
   out_341303559384211768[383] = 0;
   out_341303559384211768[384] = 0;
   out_341303559384211768[385] = 0;
   out_341303559384211768[386] = 0;
   out_341303559384211768[387] = 0;
   out_341303559384211768[388] = 0;
   out_341303559384211768[389] = 0;
   out_341303559384211768[390] = 0;
   out_341303559384211768[391] = 0;
   out_341303559384211768[392] = 0;
   out_341303559384211768[393] = 0;
   out_341303559384211768[394] = 0;
   out_341303559384211768[395] = 1.0;
   out_341303559384211768[396] = 0;
   out_341303559384211768[397] = 0;
   out_341303559384211768[398] = 0;
   out_341303559384211768[399] = 0;
   out_341303559384211768[400] = 0;
   out_341303559384211768[401] = 0;
   out_341303559384211768[402] = 0;
   out_341303559384211768[403] = 0;
   out_341303559384211768[404] = 0;
   out_341303559384211768[405] = 0;
   out_341303559384211768[406] = 0;
   out_341303559384211768[407] = 0;
   out_341303559384211768[408] = 0;
   out_341303559384211768[409] = 0;
   out_341303559384211768[410] = 0;
   out_341303559384211768[411] = 0;
   out_341303559384211768[412] = 0;
   out_341303559384211768[413] = 0;
   out_341303559384211768[414] = 0;
   out_341303559384211768[415] = 0;
   out_341303559384211768[416] = 0;
   out_341303559384211768[417] = 1.0;
   out_341303559384211768[418] = 0;
   out_341303559384211768[419] = 0;
   out_341303559384211768[420] = 0;
   out_341303559384211768[421] = 0;
   out_341303559384211768[422] = 0;
   out_341303559384211768[423] = 0;
   out_341303559384211768[424] = 0;
   out_341303559384211768[425] = 0;
   out_341303559384211768[426] = 0;
   out_341303559384211768[427] = 0;
   out_341303559384211768[428] = 0;
   out_341303559384211768[429] = 0;
   out_341303559384211768[430] = 0;
   out_341303559384211768[431] = 0;
   out_341303559384211768[432] = 0;
   out_341303559384211768[433] = 0;
   out_341303559384211768[434] = 0;
   out_341303559384211768[435] = 0;
   out_341303559384211768[436] = 0;
   out_341303559384211768[437] = 0;
   out_341303559384211768[438] = 0;
   out_341303559384211768[439] = 1.0;
   out_341303559384211768[440] = 0;
   out_341303559384211768[441] = 0;
   out_341303559384211768[442] = 0;
   out_341303559384211768[443] = 0;
   out_341303559384211768[444] = 0;
   out_341303559384211768[445] = 0;
   out_341303559384211768[446] = 0;
   out_341303559384211768[447] = 0;
   out_341303559384211768[448] = 0;
   out_341303559384211768[449] = 0;
   out_341303559384211768[450] = 0;
   out_341303559384211768[451] = 0;
   out_341303559384211768[452] = 0;
   out_341303559384211768[453] = 0;
   out_341303559384211768[454] = 0;
   out_341303559384211768[455] = 0;
   out_341303559384211768[456] = 0;
   out_341303559384211768[457] = 0;
   out_341303559384211768[458] = 0;
   out_341303559384211768[459] = 0;
   out_341303559384211768[460] = 0;
   out_341303559384211768[461] = 1.0;
}
void f_fun(double *state, double dt, double *out_4549525036970607503) {
   out_4549525036970607503[0] = dt*state[7] + state[0];
   out_4549525036970607503[1] = dt*state[8] + state[1];
   out_4549525036970607503[2] = dt*state[9] + state[2];
   out_4549525036970607503[3] = dt*(-0.5*state[4]*state[10] - 0.5*state[5]*state[11] - 0.5*state[6]*state[12]) + state[3];
   out_4549525036970607503[4] = dt*(0.5*state[3]*state[10] + 0.5*state[5]*state[12] - 0.5*state[6]*state[11]) + state[4];
   out_4549525036970607503[5] = dt*(0.5*state[3]*state[11] - 0.5*state[4]*state[12] + 0.5*state[6]*state[10]) + state[5];
   out_4549525036970607503[6] = dt*(0.5*state[3]*state[12] + 0.5*state[4]*state[11] - 0.5*state[5]*state[10]) + state[6];
   out_4549525036970607503[7] = dt*((2*state[3]*state[5] + 2*state[4]*state[6])*state[18] + (-2*state[3]*state[6] + 2*state[4]*state[5])*state[17] + (pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[16]) + state[7];
   out_4549525036970607503[8] = dt*((-2*state[3]*state[4] + 2*state[5]*state[6])*state[18] + (2*state[3]*state[6] + 2*state[4]*state[5])*state[16] + (pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[17]) + state[8];
   out_4549525036970607503[9] = dt*((2*state[3]*state[4] + 2*state[5]*state[6])*state[17] + (-2*state[3]*state[5] + 2*state[4]*state[6])*state[16] + (pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[18]) + state[9];
   out_4549525036970607503[10] = state[10];
   out_4549525036970607503[11] = state[11];
   out_4549525036970607503[12] = state[12];
   out_4549525036970607503[13] = state[13];
   out_4549525036970607503[14] = state[14];
   out_4549525036970607503[15] = state[15];
   out_4549525036970607503[16] = state[16];
   out_4549525036970607503[17] = state[17];
   out_4549525036970607503[18] = state[18];
   out_4549525036970607503[19] = state[19];
   out_4549525036970607503[20] = state[20];
   out_4549525036970607503[21] = state[21];
}
void F_fun(double *state, double dt, double *out_5133759507898990925) {
   out_5133759507898990925[0] = 1;
   out_5133759507898990925[1] = 0;
   out_5133759507898990925[2] = 0;
   out_5133759507898990925[3] = 0;
   out_5133759507898990925[4] = 0;
   out_5133759507898990925[5] = 0;
   out_5133759507898990925[6] = dt;
   out_5133759507898990925[7] = 0;
   out_5133759507898990925[8] = 0;
   out_5133759507898990925[9] = 0;
   out_5133759507898990925[10] = 0;
   out_5133759507898990925[11] = 0;
   out_5133759507898990925[12] = 0;
   out_5133759507898990925[13] = 0;
   out_5133759507898990925[14] = 0;
   out_5133759507898990925[15] = 0;
   out_5133759507898990925[16] = 0;
   out_5133759507898990925[17] = 0;
   out_5133759507898990925[18] = 0;
   out_5133759507898990925[19] = 0;
   out_5133759507898990925[20] = 0;
   out_5133759507898990925[21] = 0;
   out_5133759507898990925[22] = 1;
   out_5133759507898990925[23] = 0;
   out_5133759507898990925[24] = 0;
   out_5133759507898990925[25] = 0;
   out_5133759507898990925[26] = 0;
   out_5133759507898990925[27] = 0;
   out_5133759507898990925[28] = dt;
   out_5133759507898990925[29] = 0;
   out_5133759507898990925[30] = 0;
   out_5133759507898990925[31] = 0;
   out_5133759507898990925[32] = 0;
   out_5133759507898990925[33] = 0;
   out_5133759507898990925[34] = 0;
   out_5133759507898990925[35] = 0;
   out_5133759507898990925[36] = 0;
   out_5133759507898990925[37] = 0;
   out_5133759507898990925[38] = 0;
   out_5133759507898990925[39] = 0;
   out_5133759507898990925[40] = 0;
   out_5133759507898990925[41] = 0;
   out_5133759507898990925[42] = 0;
   out_5133759507898990925[43] = 0;
   out_5133759507898990925[44] = 1;
   out_5133759507898990925[45] = 0;
   out_5133759507898990925[46] = 0;
   out_5133759507898990925[47] = 0;
   out_5133759507898990925[48] = 0;
   out_5133759507898990925[49] = 0;
   out_5133759507898990925[50] = dt;
   out_5133759507898990925[51] = 0;
   out_5133759507898990925[52] = 0;
   out_5133759507898990925[53] = 0;
   out_5133759507898990925[54] = 0;
   out_5133759507898990925[55] = 0;
   out_5133759507898990925[56] = 0;
   out_5133759507898990925[57] = 0;
   out_5133759507898990925[58] = 0;
   out_5133759507898990925[59] = 0;
   out_5133759507898990925[60] = 0;
   out_5133759507898990925[61] = 0;
   out_5133759507898990925[62] = 0;
   out_5133759507898990925[63] = 0;
   out_5133759507898990925[64] = 0;
   out_5133759507898990925[65] = 0;
   out_5133759507898990925[66] = 1;
   out_5133759507898990925[67] = dt*((2*state[3]*state[4] + 2*state[5]*state[6])*state[11] + (-2*state[3]*state[5] + 2*state[4]*state[6])*state[10] + (pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[12]);
   out_5133759507898990925[68] = dt*((2*state[3]*state[4] - 2*state[5]*state[6])*state[12] + (-2*state[3]*state[6] - 2*state[4]*state[5])*state[10] + (-pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[11]);
   out_5133759507898990925[69] = 0;
   out_5133759507898990925[70] = 0;
   out_5133759507898990925[71] = 0;
   out_5133759507898990925[72] = dt*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2));
   out_5133759507898990925[73] = dt*(-2*state[3]*state[6] + 2*state[4]*state[5]);
   out_5133759507898990925[74] = dt*(2*state[3]*state[5] + 2*state[4]*state[6]);
   out_5133759507898990925[75] = 0;
   out_5133759507898990925[76] = 0;
   out_5133759507898990925[77] = 0;
   out_5133759507898990925[78] = 0;
   out_5133759507898990925[79] = 0;
   out_5133759507898990925[80] = 0;
   out_5133759507898990925[81] = 0;
   out_5133759507898990925[82] = 0;
   out_5133759507898990925[83] = 0;
   out_5133759507898990925[84] = 0;
   out_5133759507898990925[85] = 0;
   out_5133759507898990925[86] = 0;
   out_5133759507898990925[87] = dt*(-(2*state[3]*state[4] + 2*state[5]*state[6])*state[11] - (-2*state[3]*state[5] + 2*state[4]*state[6])*state[10] - (pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[12]);
   out_5133759507898990925[88] = 1;
   out_5133759507898990925[89] = dt*((2*state[3]*state[5] + 2*state[4]*state[6])*state[12] + (-2*state[3]*state[6] + 2*state[4]*state[5])*state[11] + (pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[10]);
   out_5133759507898990925[90] = 0;
   out_5133759507898990925[91] = 0;
   out_5133759507898990925[92] = 0;
   out_5133759507898990925[93] = dt*(2*state[3]*state[6] + 2*state[4]*state[5]);
   out_5133759507898990925[94] = dt*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2));
   out_5133759507898990925[95] = dt*(-2*state[3]*state[4] + 2*state[5]*state[6]);
   out_5133759507898990925[96] = 0;
   out_5133759507898990925[97] = 0;
   out_5133759507898990925[98] = 0;
   out_5133759507898990925[99] = 0;
   out_5133759507898990925[100] = 0;
   out_5133759507898990925[101] = 0;
   out_5133759507898990925[102] = 0;
   out_5133759507898990925[103] = 0;
   out_5133759507898990925[104] = 0;
   out_5133759507898990925[105] = 0;
   out_5133759507898990925[106] = 0;
   out_5133759507898990925[107] = 0;
   out_5133759507898990925[108] = dt*((-2*state[3]*state[4] + 2*state[5]*state[6])*state[12] + (2*state[3]*state[6] + 2*state[4]*state[5])*state[10] + (pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[11]);
   out_5133759507898990925[109] = dt*((-2*state[3]*state[5] - 2*state[4]*state[6])*state[12] + (2*state[3]*state[6] - 2*state[4]*state[5])*state[11] + (-pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) + pow(state[6], 2))*state[10]);
   out_5133759507898990925[110] = 1;
   out_5133759507898990925[111] = 0;
   out_5133759507898990925[112] = 0;
   out_5133759507898990925[113] = 0;
   out_5133759507898990925[114] = dt*(-2*state[3]*state[5] + 2*state[4]*state[6]);
   out_5133759507898990925[115] = dt*(2*state[3]*state[4] + 2*state[5]*state[6]);
   out_5133759507898990925[116] = dt*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2));
   out_5133759507898990925[117] = 0;
   out_5133759507898990925[118] = 0;
   out_5133759507898990925[119] = 0;
   out_5133759507898990925[120] = 0;
   out_5133759507898990925[121] = 0;
   out_5133759507898990925[122] = 0;
   out_5133759507898990925[123] = 0;
   out_5133759507898990925[124] = 0;
   out_5133759507898990925[125] = 0;
   out_5133759507898990925[126] = 0;
   out_5133759507898990925[127] = 0;
   out_5133759507898990925[128] = 0;
   out_5133759507898990925[129] = 0;
   out_5133759507898990925[130] = dt*((2*state[3]*state[4] + 2*state[5]*state[6])*state[17] + (-2*state[3]*state[5] + 2*state[4]*state[6])*state[16] + (pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[18]);
   out_5133759507898990925[131] = dt*((2*state[3]*state[4] - 2*state[5]*state[6])*state[18] + (-2*state[3]*state[6] - 2*state[4]*state[5])*state[16] + (-pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[17]);
   out_5133759507898990925[132] = 1;
   out_5133759507898990925[133] = 0;
   out_5133759507898990925[134] = 0;
   out_5133759507898990925[135] = 0;
   out_5133759507898990925[136] = 0;
   out_5133759507898990925[137] = 0;
   out_5133759507898990925[138] = 0;
   out_5133759507898990925[139] = 0;
   out_5133759507898990925[140] = 0;
   out_5133759507898990925[141] = dt*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2));
   out_5133759507898990925[142] = dt*(-2*state[3]*state[6] + 2*state[4]*state[5]);
   out_5133759507898990925[143] = dt*(2*state[3]*state[5] + 2*state[4]*state[6]);
   out_5133759507898990925[144] = 0;
   out_5133759507898990925[145] = 0;
   out_5133759507898990925[146] = 0;
   out_5133759507898990925[147] = 0;
   out_5133759507898990925[148] = 0;
   out_5133759507898990925[149] = 0;
   out_5133759507898990925[150] = dt*(-(2*state[3]*state[4] + 2*state[5]*state[6])*state[17] - (-2*state[3]*state[5] + 2*state[4]*state[6])*state[16] - (pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[18]);
   out_5133759507898990925[151] = 0;
   out_5133759507898990925[152] = dt*((2*state[3]*state[5] + 2*state[4]*state[6])*state[18] + (-2*state[3]*state[6] + 2*state[4]*state[5])*state[17] + (pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[16]);
   out_5133759507898990925[153] = 0;
   out_5133759507898990925[154] = 1;
   out_5133759507898990925[155] = 0;
   out_5133759507898990925[156] = 0;
   out_5133759507898990925[157] = 0;
   out_5133759507898990925[158] = 0;
   out_5133759507898990925[159] = 0;
   out_5133759507898990925[160] = 0;
   out_5133759507898990925[161] = 0;
   out_5133759507898990925[162] = dt*(2*state[3]*state[6] + 2*state[4]*state[5]);
   out_5133759507898990925[163] = dt*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2));
   out_5133759507898990925[164] = dt*(-2*state[3]*state[4] + 2*state[5]*state[6]);
   out_5133759507898990925[165] = 0;
   out_5133759507898990925[166] = 0;
   out_5133759507898990925[167] = 0;
   out_5133759507898990925[168] = 0;
   out_5133759507898990925[169] = 0;
   out_5133759507898990925[170] = 0;
   out_5133759507898990925[171] = dt*((-2*state[3]*state[4] + 2*state[5]*state[6])*state[18] + (2*state[3]*state[6] + 2*state[4]*state[5])*state[16] + (pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[17]);
   out_5133759507898990925[172] = dt*((-2*state[3]*state[5] - 2*state[4]*state[6])*state[18] + (2*state[3]*state[6] - 2*state[4]*state[5])*state[17] + (-pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) + pow(state[6], 2))*state[16]);
   out_5133759507898990925[173] = 0;
   out_5133759507898990925[174] = 0;
   out_5133759507898990925[175] = 0;
   out_5133759507898990925[176] = 1;
   out_5133759507898990925[177] = 0;
   out_5133759507898990925[178] = 0;
   out_5133759507898990925[179] = 0;
   out_5133759507898990925[180] = 0;
   out_5133759507898990925[181] = 0;
   out_5133759507898990925[182] = 0;
   out_5133759507898990925[183] = dt*(-2*state[3]*state[5] + 2*state[4]*state[6]);
   out_5133759507898990925[184] = dt*(2*state[3]*state[4] + 2*state[5]*state[6]);
   out_5133759507898990925[185] = dt*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2));
   out_5133759507898990925[186] = 0;
   out_5133759507898990925[187] = 0;
   out_5133759507898990925[188] = 0;
   out_5133759507898990925[189] = 0;
   out_5133759507898990925[190] = 0;
   out_5133759507898990925[191] = 0;
   out_5133759507898990925[192] = 0;
   out_5133759507898990925[193] = 0;
   out_5133759507898990925[194] = 0;
   out_5133759507898990925[195] = 0;
   out_5133759507898990925[196] = 0;
   out_5133759507898990925[197] = 0;
   out_5133759507898990925[198] = 1;
   out_5133759507898990925[199] = 0;
   out_5133759507898990925[200] = 0;
   out_5133759507898990925[201] = 0;
   out_5133759507898990925[202] = 0;
   out_5133759507898990925[203] = 0;
   out_5133759507898990925[204] = 0;
   out_5133759507898990925[205] = 0;
   out_5133759507898990925[206] = 0;
   out_5133759507898990925[207] = 0;
   out_5133759507898990925[208] = 0;
   out_5133759507898990925[209] = 0;
   out_5133759507898990925[210] = 0;
   out_5133759507898990925[211] = 0;
   out_5133759507898990925[212] = 0;
   out_5133759507898990925[213] = 0;
   out_5133759507898990925[214] = 0;
   out_5133759507898990925[215] = 0;
   out_5133759507898990925[216] = 0;
   out_5133759507898990925[217] = 0;
   out_5133759507898990925[218] = 0;
   out_5133759507898990925[219] = 0;
   out_5133759507898990925[220] = 1;
   out_5133759507898990925[221] = 0;
   out_5133759507898990925[222] = 0;
   out_5133759507898990925[223] = 0;
   out_5133759507898990925[224] = 0;
   out_5133759507898990925[225] = 0;
   out_5133759507898990925[226] = 0;
   out_5133759507898990925[227] = 0;
   out_5133759507898990925[228] = 0;
   out_5133759507898990925[229] = 0;
   out_5133759507898990925[230] = 0;
   out_5133759507898990925[231] = 0;
   out_5133759507898990925[232] = 0;
   out_5133759507898990925[233] = 0;
   out_5133759507898990925[234] = 0;
   out_5133759507898990925[235] = 0;
   out_5133759507898990925[236] = 0;
   out_5133759507898990925[237] = 0;
   out_5133759507898990925[238] = 0;
   out_5133759507898990925[239] = 0;
   out_5133759507898990925[240] = 0;
   out_5133759507898990925[241] = 0;
   out_5133759507898990925[242] = 1;
   out_5133759507898990925[243] = 0;
   out_5133759507898990925[244] = 0;
   out_5133759507898990925[245] = 0;
   out_5133759507898990925[246] = 0;
   out_5133759507898990925[247] = 0;
   out_5133759507898990925[248] = 0;
   out_5133759507898990925[249] = 0;
   out_5133759507898990925[250] = 0;
   out_5133759507898990925[251] = 0;
   out_5133759507898990925[252] = 0;
   out_5133759507898990925[253] = 0;
   out_5133759507898990925[254] = 0;
   out_5133759507898990925[255] = 0;
   out_5133759507898990925[256] = 0;
   out_5133759507898990925[257] = 0;
   out_5133759507898990925[258] = 0;
   out_5133759507898990925[259] = 0;
   out_5133759507898990925[260] = 0;
   out_5133759507898990925[261] = 0;
   out_5133759507898990925[262] = 0;
   out_5133759507898990925[263] = 0;
   out_5133759507898990925[264] = 1;
   out_5133759507898990925[265] = 0;
   out_5133759507898990925[266] = 0;
   out_5133759507898990925[267] = 0;
   out_5133759507898990925[268] = 0;
   out_5133759507898990925[269] = 0;
   out_5133759507898990925[270] = 0;
   out_5133759507898990925[271] = 0;
   out_5133759507898990925[272] = 0;
   out_5133759507898990925[273] = 0;
   out_5133759507898990925[274] = 0;
   out_5133759507898990925[275] = 0;
   out_5133759507898990925[276] = 0;
   out_5133759507898990925[277] = 0;
   out_5133759507898990925[278] = 0;
   out_5133759507898990925[279] = 0;
   out_5133759507898990925[280] = 0;
   out_5133759507898990925[281] = 0;
   out_5133759507898990925[282] = 0;
   out_5133759507898990925[283] = 0;
   out_5133759507898990925[284] = 0;
   out_5133759507898990925[285] = 0;
   out_5133759507898990925[286] = 1;
   out_5133759507898990925[287] = 0;
   out_5133759507898990925[288] = 0;
   out_5133759507898990925[289] = 0;
   out_5133759507898990925[290] = 0;
   out_5133759507898990925[291] = 0;
   out_5133759507898990925[292] = 0;
   out_5133759507898990925[293] = 0;
   out_5133759507898990925[294] = 0;
   out_5133759507898990925[295] = 0;
   out_5133759507898990925[296] = 0;
   out_5133759507898990925[297] = 0;
   out_5133759507898990925[298] = 0;
   out_5133759507898990925[299] = 0;
   out_5133759507898990925[300] = 0;
   out_5133759507898990925[301] = 0;
   out_5133759507898990925[302] = 0;
   out_5133759507898990925[303] = 0;
   out_5133759507898990925[304] = 0;
   out_5133759507898990925[305] = 0;
   out_5133759507898990925[306] = 0;
   out_5133759507898990925[307] = 0;
   out_5133759507898990925[308] = 1;
   out_5133759507898990925[309] = 0;
   out_5133759507898990925[310] = 0;
   out_5133759507898990925[311] = 0;
   out_5133759507898990925[312] = 0;
   out_5133759507898990925[313] = 0;
   out_5133759507898990925[314] = 0;
   out_5133759507898990925[315] = 0;
   out_5133759507898990925[316] = 0;
   out_5133759507898990925[317] = 0;
   out_5133759507898990925[318] = 0;
   out_5133759507898990925[319] = 0;
   out_5133759507898990925[320] = 0;
   out_5133759507898990925[321] = 0;
   out_5133759507898990925[322] = 0;
   out_5133759507898990925[323] = 0;
   out_5133759507898990925[324] = 0;
   out_5133759507898990925[325] = 0;
   out_5133759507898990925[326] = 0;
   out_5133759507898990925[327] = 0;
   out_5133759507898990925[328] = 0;
   out_5133759507898990925[329] = 0;
   out_5133759507898990925[330] = 1;
   out_5133759507898990925[331] = 0;
   out_5133759507898990925[332] = 0;
   out_5133759507898990925[333] = 0;
   out_5133759507898990925[334] = 0;
   out_5133759507898990925[335] = 0;
   out_5133759507898990925[336] = 0;
   out_5133759507898990925[337] = 0;
   out_5133759507898990925[338] = 0;
   out_5133759507898990925[339] = 0;
   out_5133759507898990925[340] = 0;
   out_5133759507898990925[341] = 0;
   out_5133759507898990925[342] = 0;
   out_5133759507898990925[343] = 0;
   out_5133759507898990925[344] = 0;
   out_5133759507898990925[345] = 0;
   out_5133759507898990925[346] = 0;
   out_5133759507898990925[347] = 0;
   out_5133759507898990925[348] = 0;
   out_5133759507898990925[349] = 0;
   out_5133759507898990925[350] = 0;
   out_5133759507898990925[351] = 0;
   out_5133759507898990925[352] = 1;
   out_5133759507898990925[353] = 0;
   out_5133759507898990925[354] = 0;
   out_5133759507898990925[355] = 0;
   out_5133759507898990925[356] = 0;
   out_5133759507898990925[357] = 0;
   out_5133759507898990925[358] = 0;
   out_5133759507898990925[359] = 0;
   out_5133759507898990925[360] = 0;
   out_5133759507898990925[361] = 0;
   out_5133759507898990925[362] = 0;
   out_5133759507898990925[363] = 0;
   out_5133759507898990925[364] = 0;
   out_5133759507898990925[365] = 0;
   out_5133759507898990925[366] = 0;
   out_5133759507898990925[367] = 0;
   out_5133759507898990925[368] = 0;
   out_5133759507898990925[369] = 0;
   out_5133759507898990925[370] = 0;
   out_5133759507898990925[371] = 0;
   out_5133759507898990925[372] = 0;
   out_5133759507898990925[373] = 0;
   out_5133759507898990925[374] = 1;
   out_5133759507898990925[375] = 0;
   out_5133759507898990925[376] = 0;
   out_5133759507898990925[377] = 0;
   out_5133759507898990925[378] = 0;
   out_5133759507898990925[379] = 0;
   out_5133759507898990925[380] = 0;
   out_5133759507898990925[381] = 0;
   out_5133759507898990925[382] = 0;
   out_5133759507898990925[383] = 0;
   out_5133759507898990925[384] = 0;
   out_5133759507898990925[385] = 0;
   out_5133759507898990925[386] = 0;
   out_5133759507898990925[387] = 0;
   out_5133759507898990925[388] = 0;
   out_5133759507898990925[389] = 0;
   out_5133759507898990925[390] = 0;
   out_5133759507898990925[391] = 0;
   out_5133759507898990925[392] = 0;
   out_5133759507898990925[393] = 0;
   out_5133759507898990925[394] = 0;
   out_5133759507898990925[395] = 0;
   out_5133759507898990925[396] = 1;
   out_5133759507898990925[397] = 0;
   out_5133759507898990925[398] = 0;
   out_5133759507898990925[399] = 0;
   out_5133759507898990925[400] = 0;
   out_5133759507898990925[401] = 0;
   out_5133759507898990925[402] = 0;
   out_5133759507898990925[403] = 0;
   out_5133759507898990925[404] = 0;
   out_5133759507898990925[405] = 0;
   out_5133759507898990925[406] = 0;
   out_5133759507898990925[407] = 0;
   out_5133759507898990925[408] = 0;
   out_5133759507898990925[409] = 0;
   out_5133759507898990925[410] = 0;
   out_5133759507898990925[411] = 0;
   out_5133759507898990925[412] = 0;
   out_5133759507898990925[413] = 0;
   out_5133759507898990925[414] = 0;
   out_5133759507898990925[415] = 0;
   out_5133759507898990925[416] = 0;
   out_5133759507898990925[417] = 0;
   out_5133759507898990925[418] = 1;
   out_5133759507898990925[419] = 0;
   out_5133759507898990925[420] = 0;
   out_5133759507898990925[421] = 0;
   out_5133759507898990925[422] = 0;
   out_5133759507898990925[423] = 0;
   out_5133759507898990925[424] = 0;
   out_5133759507898990925[425] = 0;
   out_5133759507898990925[426] = 0;
   out_5133759507898990925[427] = 0;
   out_5133759507898990925[428] = 0;
   out_5133759507898990925[429] = 0;
   out_5133759507898990925[430] = 0;
   out_5133759507898990925[431] = 0;
   out_5133759507898990925[432] = 0;
   out_5133759507898990925[433] = 0;
   out_5133759507898990925[434] = 0;
   out_5133759507898990925[435] = 0;
   out_5133759507898990925[436] = 0;
   out_5133759507898990925[437] = 0;
   out_5133759507898990925[438] = 0;
   out_5133759507898990925[439] = 0;
   out_5133759507898990925[440] = 1;
}
void h_4(double *state, double *unused, double *out_6872450210111746980) {
   out_6872450210111746980[0] = state[10] + state[13];
   out_6872450210111746980[1] = state[11] + state[14];
   out_6872450210111746980[2] = state[12] + state[15];
}
void H_4(double *state, double *unused, double *out_2937396917593955740) {
   out_2937396917593955740[0] = 0;
   out_2937396917593955740[1] = 0;
   out_2937396917593955740[2] = 0;
   out_2937396917593955740[3] = 0;
   out_2937396917593955740[4] = 0;
   out_2937396917593955740[5] = 0;
   out_2937396917593955740[6] = 0;
   out_2937396917593955740[7] = 0;
   out_2937396917593955740[8] = 0;
   out_2937396917593955740[9] = 0;
   out_2937396917593955740[10] = 1;
   out_2937396917593955740[11] = 0;
   out_2937396917593955740[12] = 0;
   out_2937396917593955740[13] = 1;
   out_2937396917593955740[14] = 0;
   out_2937396917593955740[15] = 0;
   out_2937396917593955740[16] = 0;
   out_2937396917593955740[17] = 0;
   out_2937396917593955740[18] = 0;
   out_2937396917593955740[19] = 0;
   out_2937396917593955740[20] = 0;
   out_2937396917593955740[21] = 0;
   out_2937396917593955740[22] = 0;
   out_2937396917593955740[23] = 0;
   out_2937396917593955740[24] = 0;
   out_2937396917593955740[25] = 0;
   out_2937396917593955740[26] = 0;
   out_2937396917593955740[27] = 0;
   out_2937396917593955740[28] = 0;
   out_2937396917593955740[29] = 0;
   out_2937396917593955740[30] = 0;
   out_2937396917593955740[31] = 0;
   out_2937396917593955740[32] = 0;
   out_2937396917593955740[33] = 1;
   out_2937396917593955740[34] = 0;
   out_2937396917593955740[35] = 0;
   out_2937396917593955740[36] = 1;
   out_2937396917593955740[37] = 0;
   out_2937396917593955740[38] = 0;
   out_2937396917593955740[39] = 0;
   out_2937396917593955740[40] = 0;
   out_2937396917593955740[41] = 0;
   out_2937396917593955740[42] = 0;
   out_2937396917593955740[43] = 0;
   out_2937396917593955740[44] = 0;
   out_2937396917593955740[45] = 0;
   out_2937396917593955740[46] = 0;
   out_2937396917593955740[47] = 0;
   out_2937396917593955740[48] = 0;
   out_2937396917593955740[49] = 0;
   out_2937396917593955740[50] = 0;
   out_2937396917593955740[51] = 0;
   out_2937396917593955740[52] = 0;
   out_2937396917593955740[53] = 0;
   out_2937396917593955740[54] = 0;
   out_2937396917593955740[55] = 0;
   out_2937396917593955740[56] = 1;
   out_2937396917593955740[57] = 0;
   out_2937396917593955740[58] = 0;
   out_2937396917593955740[59] = 1;
   out_2937396917593955740[60] = 0;
   out_2937396917593955740[61] = 0;
   out_2937396917593955740[62] = 0;
   out_2937396917593955740[63] = 0;
   out_2937396917593955740[64] = 0;
   out_2937396917593955740[65] = 0;
}
void h_9(double *state, double *unused, double *out_8735722694958550472) {
   out_8735722694958550472[0] = state[10];
   out_8735722694958550472[1] = state[11];
   out_8735722694958550472[2] = state[12];
}
void H_9(double *state, double *unused, double *out_3178586564223546385) {
   out_3178586564223546385[0] = 0;
   out_3178586564223546385[1] = 0;
   out_3178586564223546385[2] = 0;
   out_3178586564223546385[3] = 0;
   out_3178586564223546385[4] = 0;
   out_3178586564223546385[5] = 0;
   out_3178586564223546385[6] = 0;
   out_3178586564223546385[7] = 0;
   out_3178586564223546385[8] = 0;
   out_3178586564223546385[9] = 0;
   out_3178586564223546385[10] = 1;
   out_3178586564223546385[11] = 0;
   out_3178586564223546385[12] = 0;
   out_3178586564223546385[13] = 0;
   out_3178586564223546385[14] = 0;
   out_3178586564223546385[15] = 0;
   out_3178586564223546385[16] = 0;
   out_3178586564223546385[17] = 0;
   out_3178586564223546385[18] = 0;
   out_3178586564223546385[19] = 0;
   out_3178586564223546385[20] = 0;
   out_3178586564223546385[21] = 0;
   out_3178586564223546385[22] = 0;
   out_3178586564223546385[23] = 0;
   out_3178586564223546385[24] = 0;
   out_3178586564223546385[25] = 0;
   out_3178586564223546385[26] = 0;
   out_3178586564223546385[27] = 0;
   out_3178586564223546385[28] = 0;
   out_3178586564223546385[29] = 0;
   out_3178586564223546385[30] = 0;
   out_3178586564223546385[31] = 0;
   out_3178586564223546385[32] = 0;
   out_3178586564223546385[33] = 1;
   out_3178586564223546385[34] = 0;
   out_3178586564223546385[35] = 0;
   out_3178586564223546385[36] = 0;
   out_3178586564223546385[37] = 0;
   out_3178586564223546385[38] = 0;
   out_3178586564223546385[39] = 0;
   out_3178586564223546385[40] = 0;
   out_3178586564223546385[41] = 0;
   out_3178586564223546385[42] = 0;
   out_3178586564223546385[43] = 0;
   out_3178586564223546385[44] = 0;
   out_3178586564223546385[45] = 0;
   out_3178586564223546385[46] = 0;
   out_3178586564223546385[47] = 0;
   out_3178586564223546385[48] = 0;
   out_3178586564223546385[49] = 0;
   out_3178586564223546385[50] = 0;
   out_3178586564223546385[51] = 0;
   out_3178586564223546385[52] = 0;
   out_3178586564223546385[53] = 0;
   out_3178586564223546385[54] = 0;
   out_3178586564223546385[55] = 0;
   out_3178586564223546385[56] = 1;
   out_3178586564223546385[57] = 0;
   out_3178586564223546385[58] = 0;
   out_3178586564223546385[59] = 0;
   out_3178586564223546385[60] = 0;
   out_3178586564223546385[61] = 0;
   out_3178586564223546385[62] = 0;
   out_3178586564223546385[63] = 0;
   out_3178586564223546385[64] = 0;
   out_3178586564223546385[65] = 0;
}
void h_10(double *state, double *unused, double *out_4239705948005809237) {
   out_4239705948005809237[0] = 398600500000000.0*(-2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2] + 398600500000000.0*(2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1] + 398600500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[0] + state[16] + state[19];
   out_4239705948005809237[1] = 398600500000000.0*(2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2] + 398600500000000.0*(-2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0] + 398600500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[1] + state[17] + state[20];
   out_4239705948005809237[2] = 398600500000000.0*(-2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1] + 398600500000000.0*(2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0] + 398600500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[2] + state[18] + state[21];
}
void H_10(double *state, double *unused, double *out_4956943889339789869) {
   out_4956943889339789869[0] = -1195801500000000.0*(-2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[2] - 1195801500000000.0*(2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[1] - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*pow(state[0], 2) + 398600500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2));
   out_4956943889339789869[1] = -1195801500000000.0*(-2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[1]*state[2] - 1195801500000000.0*(2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*pow(state[1], 2) + 398600500000000.0*(2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5) - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[0]*state[1];
   out_4956943889339789869[2] = -1195801500000000.0*(-2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*pow(state[2], 2) + 398600500000000.0*(-2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5) - 1195801500000000.0*(2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[1]*state[2] - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[0]*state[2];
   out_4956943889339789869[3] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[3] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[6] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[5];
   out_4956943889339789869[4] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[4] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[5] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[6];
   out_4956943889339789869[5] = -797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[5] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[4] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[3];
   out_4956943889339789869[6] = -797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[6] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[3] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[4];
   out_4956943889339789869[7] = 0;
   out_4956943889339789869[8] = 0;
   out_4956943889339789869[9] = 0;
   out_4956943889339789869[10] = 0;
   out_4956943889339789869[11] = 0;
   out_4956943889339789869[12] = 0;
   out_4956943889339789869[13] = 0;
   out_4956943889339789869[14] = 0;
   out_4956943889339789869[15] = 0;
   out_4956943889339789869[16] = 1;
   out_4956943889339789869[17] = 0;
   out_4956943889339789869[18] = 0;
   out_4956943889339789869[19] = 1;
   out_4956943889339789869[20] = 0;
   out_4956943889339789869[21] = 0;
   out_4956943889339789869[22] = -1195801500000000.0*(2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[2] - 1195801500000000.0*(-2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*pow(state[0], 2) + 398600500000000.0*(-2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5) - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[0]*state[1];
   out_4956943889339789869[23] = -1195801500000000.0*(2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[1]*state[2] - 1195801500000000.0*(-2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[1] - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*pow(state[1], 2) + 398600500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2));
   out_4956943889339789869[24] = -1195801500000000.0*(2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*pow(state[2], 2) + 398600500000000.0*(2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5) - 1195801500000000.0*(-2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[2] - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[1]*state[2];
   out_4956943889339789869[25] = -797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[6] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[3] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[4];
   out_4956943889339789869[26] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[5] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[4] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[3];
   out_4956943889339789869[27] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[4] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[5] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[6];
   out_4956943889339789869[28] = -797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[3] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[6] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[5];
   out_4956943889339789869[29] = 0;
   out_4956943889339789869[30] = 0;
   out_4956943889339789869[31] = 0;
   out_4956943889339789869[32] = 0;
   out_4956943889339789869[33] = 0;
   out_4956943889339789869[34] = 0;
   out_4956943889339789869[35] = 0;
   out_4956943889339789869[36] = 0;
   out_4956943889339789869[37] = 0;
   out_4956943889339789869[38] = 0;
   out_4956943889339789869[39] = 1;
   out_4956943889339789869[40] = 0;
   out_4956943889339789869[41] = 0;
   out_4956943889339789869[42] = 1;
   out_4956943889339789869[43] = 0;
   out_4956943889339789869[44] = -1195801500000000.0*(-2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[1] - 1195801500000000.0*(2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*pow(state[0], 2) + 398600500000000.0*(2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5) - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[0]*state[2];
   out_4956943889339789869[45] = -1195801500000000.0*(-2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*pow(state[1], 2) + 398600500000000.0*(-2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5) - 1195801500000000.0*(2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[1] - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[1]*state[2];
   out_4956943889339789869[46] = -1195801500000000.0*(-2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[1]*state[2] - 1195801500000000.0*(2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[2] - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*pow(state[2], 2) + 398600500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2));
   out_4956943889339789869[47] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[5] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[4] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[3];
   out_4956943889339789869[48] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[6] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[3] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[4];
   out_4956943889339789869[49] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[3] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[6] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[5];
   out_4956943889339789869[50] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[4] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[5] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[6];
   out_4956943889339789869[51] = 0;
   out_4956943889339789869[52] = 0;
   out_4956943889339789869[53] = 0;
   out_4956943889339789869[54] = 0;
   out_4956943889339789869[55] = 0;
   out_4956943889339789869[56] = 0;
   out_4956943889339789869[57] = 0;
   out_4956943889339789869[58] = 0;
   out_4956943889339789869[59] = 0;
   out_4956943889339789869[60] = 0;
   out_4956943889339789869[61] = 0;
   out_4956943889339789869[62] = 1;
   out_4956943889339789869[63] = 0;
   out_4956943889339789869[64] = 0;
   out_4956943889339789869[65] = 1;
}
void h_12(double *state, double *unused, double *out_3848117259651593996) {
   out_3848117259651593996[0] = state[0];
   out_3848117259651593996[1] = state[1];
   out_3848117259651593996[2] = state[2];
}
void H_12(double *state, double *unused, double *out_3558495942641549407) {
   out_3558495942641549407[0] = 1;
   out_3558495942641549407[1] = 0;
   out_3558495942641549407[2] = 0;
   out_3558495942641549407[3] = 0;
   out_3558495942641549407[4] = 0;
   out_3558495942641549407[5] = 0;
   out_3558495942641549407[6] = 0;
   out_3558495942641549407[7] = 0;
   out_3558495942641549407[8] = 0;
   out_3558495942641549407[9] = 0;
   out_3558495942641549407[10] = 0;
   out_3558495942641549407[11] = 0;
   out_3558495942641549407[12] = 0;
   out_3558495942641549407[13] = 0;
   out_3558495942641549407[14] = 0;
   out_3558495942641549407[15] = 0;
   out_3558495942641549407[16] = 0;
   out_3558495942641549407[17] = 0;
   out_3558495942641549407[18] = 0;
   out_3558495942641549407[19] = 0;
   out_3558495942641549407[20] = 0;
   out_3558495942641549407[21] = 0;
   out_3558495942641549407[22] = 0;
   out_3558495942641549407[23] = 1;
   out_3558495942641549407[24] = 0;
   out_3558495942641549407[25] = 0;
   out_3558495942641549407[26] = 0;
   out_3558495942641549407[27] = 0;
   out_3558495942641549407[28] = 0;
   out_3558495942641549407[29] = 0;
   out_3558495942641549407[30] = 0;
   out_3558495942641549407[31] = 0;
   out_3558495942641549407[32] = 0;
   out_3558495942641549407[33] = 0;
   out_3558495942641549407[34] = 0;
   out_3558495942641549407[35] = 0;
   out_3558495942641549407[36] = 0;
   out_3558495942641549407[37] = 0;
   out_3558495942641549407[38] = 0;
   out_3558495942641549407[39] = 0;
   out_3558495942641549407[40] = 0;
   out_3558495942641549407[41] = 0;
   out_3558495942641549407[42] = 0;
   out_3558495942641549407[43] = 0;
   out_3558495942641549407[44] = 0;
   out_3558495942641549407[45] = 0;
   out_3558495942641549407[46] = 1;
   out_3558495942641549407[47] = 0;
   out_3558495942641549407[48] = 0;
   out_3558495942641549407[49] = 0;
   out_3558495942641549407[50] = 0;
   out_3558495942641549407[51] = 0;
   out_3558495942641549407[52] = 0;
   out_3558495942641549407[53] = 0;
   out_3558495942641549407[54] = 0;
   out_3558495942641549407[55] = 0;
   out_3558495942641549407[56] = 0;
   out_3558495942641549407[57] = 0;
   out_3558495942641549407[58] = 0;
   out_3558495942641549407[59] = 0;
   out_3558495942641549407[60] = 0;
   out_3558495942641549407[61] = 0;
   out_3558495942641549407[62] = 0;
   out_3558495942641549407[63] = 0;
   out_3558495942641549407[64] = 0;
   out_3558495942641549407[65] = 0;
}
void h_35(double *state, double *unused, double *out_854595621797169640) {
   out_854595621797169640[0] = state[7];
   out_854595621797169640[1] = state[8];
   out_854595621797169640[2] = state[9];
}
void H_35(double *state, double *unused, double *out_6304058974966563116) {
   out_6304058974966563116[0] = 0;
   out_6304058974966563116[1] = 0;
   out_6304058974966563116[2] = 0;
   out_6304058974966563116[3] = 0;
   out_6304058974966563116[4] = 0;
   out_6304058974966563116[5] = 0;
   out_6304058974966563116[6] = 0;
   out_6304058974966563116[7] = 1;
   out_6304058974966563116[8] = 0;
   out_6304058974966563116[9] = 0;
   out_6304058974966563116[10] = 0;
   out_6304058974966563116[11] = 0;
   out_6304058974966563116[12] = 0;
   out_6304058974966563116[13] = 0;
   out_6304058974966563116[14] = 0;
   out_6304058974966563116[15] = 0;
   out_6304058974966563116[16] = 0;
   out_6304058974966563116[17] = 0;
   out_6304058974966563116[18] = 0;
   out_6304058974966563116[19] = 0;
   out_6304058974966563116[20] = 0;
   out_6304058974966563116[21] = 0;
   out_6304058974966563116[22] = 0;
   out_6304058974966563116[23] = 0;
   out_6304058974966563116[24] = 0;
   out_6304058974966563116[25] = 0;
   out_6304058974966563116[26] = 0;
   out_6304058974966563116[27] = 0;
   out_6304058974966563116[28] = 0;
   out_6304058974966563116[29] = 0;
   out_6304058974966563116[30] = 1;
   out_6304058974966563116[31] = 0;
   out_6304058974966563116[32] = 0;
   out_6304058974966563116[33] = 0;
   out_6304058974966563116[34] = 0;
   out_6304058974966563116[35] = 0;
   out_6304058974966563116[36] = 0;
   out_6304058974966563116[37] = 0;
   out_6304058974966563116[38] = 0;
   out_6304058974966563116[39] = 0;
   out_6304058974966563116[40] = 0;
   out_6304058974966563116[41] = 0;
   out_6304058974966563116[42] = 0;
   out_6304058974966563116[43] = 0;
   out_6304058974966563116[44] = 0;
   out_6304058974966563116[45] = 0;
   out_6304058974966563116[46] = 0;
   out_6304058974966563116[47] = 0;
   out_6304058974966563116[48] = 0;
   out_6304058974966563116[49] = 0;
   out_6304058974966563116[50] = 0;
   out_6304058974966563116[51] = 0;
   out_6304058974966563116[52] = 0;
   out_6304058974966563116[53] = 1;
   out_6304058974966563116[54] = 0;
   out_6304058974966563116[55] = 0;
   out_6304058974966563116[56] = 0;
   out_6304058974966563116[57] = 0;
   out_6304058974966563116[58] = 0;
   out_6304058974966563116[59] = 0;
   out_6304058974966563116[60] = 0;
   out_6304058974966563116[61] = 0;
   out_6304058974966563116[62] = 0;
   out_6304058974966563116[63] = 0;
   out_6304058974966563116[64] = 0;
   out_6304058974966563116[65] = 0;
}
void h_32(double *state, double *unused, double *out_2979708909891080243) {
   out_2979708909891080243[0] = state[3];
   out_2979708909891080243[1] = state[4];
   out_2979708909891080243[2] = state[5];
   out_2979708909891080243[3] = state[6];
}
void H_32(double *state, double *unused, double *out_9087717139384980709) {
   out_9087717139384980709[0] = 0;
   out_9087717139384980709[1] = 0;
   out_9087717139384980709[2] = 0;
   out_9087717139384980709[3] = 1;
   out_9087717139384980709[4] = 0;
   out_9087717139384980709[5] = 0;
   out_9087717139384980709[6] = 0;
   out_9087717139384980709[7] = 0;
   out_9087717139384980709[8] = 0;
   out_9087717139384980709[9] = 0;
   out_9087717139384980709[10] = 0;
   out_9087717139384980709[11] = 0;
   out_9087717139384980709[12] = 0;
   out_9087717139384980709[13] = 0;
   out_9087717139384980709[14] = 0;
   out_9087717139384980709[15] = 0;
   out_9087717139384980709[16] = 0;
   out_9087717139384980709[17] = 0;
   out_9087717139384980709[18] = 0;
   out_9087717139384980709[19] = 0;
   out_9087717139384980709[20] = 0;
   out_9087717139384980709[21] = 0;
   out_9087717139384980709[22] = 0;
   out_9087717139384980709[23] = 0;
   out_9087717139384980709[24] = 0;
   out_9087717139384980709[25] = 0;
   out_9087717139384980709[26] = 1;
   out_9087717139384980709[27] = 0;
   out_9087717139384980709[28] = 0;
   out_9087717139384980709[29] = 0;
   out_9087717139384980709[30] = 0;
   out_9087717139384980709[31] = 0;
   out_9087717139384980709[32] = 0;
   out_9087717139384980709[33] = 0;
   out_9087717139384980709[34] = 0;
   out_9087717139384980709[35] = 0;
   out_9087717139384980709[36] = 0;
   out_9087717139384980709[37] = 0;
   out_9087717139384980709[38] = 0;
   out_9087717139384980709[39] = 0;
   out_9087717139384980709[40] = 0;
   out_9087717139384980709[41] = 0;
   out_9087717139384980709[42] = 0;
   out_9087717139384980709[43] = 0;
   out_9087717139384980709[44] = 0;
   out_9087717139384980709[45] = 0;
   out_9087717139384980709[46] = 0;
   out_9087717139384980709[47] = 0;
   out_9087717139384980709[48] = 0;
   out_9087717139384980709[49] = 1;
   out_9087717139384980709[50] = 0;
   out_9087717139384980709[51] = 0;
   out_9087717139384980709[52] = 0;
   out_9087717139384980709[53] = 0;
   out_9087717139384980709[54] = 0;
   out_9087717139384980709[55] = 0;
   out_9087717139384980709[56] = 0;
   out_9087717139384980709[57] = 0;
   out_9087717139384980709[58] = 0;
   out_9087717139384980709[59] = 0;
   out_9087717139384980709[60] = 0;
   out_9087717139384980709[61] = 0;
   out_9087717139384980709[62] = 0;
   out_9087717139384980709[63] = 0;
   out_9087717139384980709[64] = 0;
   out_9087717139384980709[65] = 0;
   out_9087717139384980709[66] = 0;
   out_9087717139384980709[67] = 0;
   out_9087717139384980709[68] = 0;
   out_9087717139384980709[69] = 0;
   out_9087717139384980709[70] = 0;
   out_9087717139384980709[71] = 0;
   out_9087717139384980709[72] = 1;
   out_9087717139384980709[73] = 0;
   out_9087717139384980709[74] = 0;
   out_9087717139384980709[75] = 0;
   out_9087717139384980709[76] = 0;
   out_9087717139384980709[77] = 0;
   out_9087717139384980709[78] = 0;
   out_9087717139384980709[79] = 0;
   out_9087717139384980709[80] = 0;
   out_9087717139384980709[81] = 0;
   out_9087717139384980709[82] = 0;
   out_9087717139384980709[83] = 0;
   out_9087717139384980709[84] = 0;
   out_9087717139384980709[85] = 0;
   out_9087717139384980709[86] = 0;
   out_9087717139384980709[87] = 0;
}
void h_13(double *state, double *unused, double *out_7896661243212334910) {
   out_7896661243212334910[0] = (-2*state[3]*state[5] + 2*state[4]*state[6])*state[9] + (2*state[3]*state[6] + 2*state[4]*state[5])*state[8] + (pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[7];
   out_7896661243212334910[1] = (2*state[3]*state[4] + 2*state[5]*state[6])*state[9] + (-2*state[3]*state[6] + 2*state[4]*state[5])*state[7] + (pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[8];
   out_7896661243212334910[2] = (-2*state[3]*state[4] + 2*state[5]*state[6])*state[8] + (2*state[3]*state[5] + 2*state[4]*state[6])*state[7] + (pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[9];
}
void H_13(double *state, double *unused, double *out_83856576196215707) {
   out_83856576196215707[0] = 0;
   out_83856576196215707[1] = 0;
   out_83856576196215707[2] = 0;
   out_83856576196215707[3] = 2*state[3]*state[7] - 2*state[5]*state[9] + 2*state[6]*state[8];
   out_83856576196215707[4] = 2*state[4]*state[7] + 2*state[5]*state[8] + 2*state[6]*state[9];
   out_83856576196215707[5] = -2*state[3]*state[9] + 2*state[4]*state[8] - 2*state[5]*state[7];
   out_83856576196215707[6] = 2*state[3]*state[8] + 2*state[4]*state[9] - 2*state[6]*state[7];
   out_83856576196215707[7] = pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2);
   out_83856576196215707[8] = 2*state[3]*state[6] + 2*state[4]*state[5];
   out_83856576196215707[9] = -2*state[3]*state[5] + 2*state[4]*state[6];
   out_83856576196215707[10] = 0;
   out_83856576196215707[11] = 0;
   out_83856576196215707[12] = 0;
   out_83856576196215707[13] = 0;
   out_83856576196215707[14] = 0;
   out_83856576196215707[15] = 0;
   out_83856576196215707[16] = 0;
   out_83856576196215707[17] = 0;
   out_83856576196215707[18] = 0;
   out_83856576196215707[19] = 0;
   out_83856576196215707[20] = 0;
   out_83856576196215707[21] = 0;
   out_83856576196215707[22] = 0;
   out_83856576196215707[23] = 0;
   out_83856576196215707[24] = 0;
   out_83856576196215707[25] = 2*state[3]*state[8] + 2*state[4]*state[9] - 2*state[6]*state[7];
   out_83856576196215707[26] = 2*state[3]*state[9] - 2*state[4]*state[8] + 2*state[5]*state[7];
   out_83856576196215707[27] = 2*state[4]*state[7] + 2*state[5]*state[8] + 2*state[6]*state[9];
   out_83856576196215707[28] = -2*state[3]*state[7] + 2*state[5]*state[9] - 2*state[6]*state[8];
   out_83856576196215707[29] = -2*state[3]*state[6] + 2*state[4]*state[5];
   out_83856576196215707[30] = pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2);
   out_83856576196215707[31] = 2*state[3]*state[4] + 2*state[5]*state[6];
   out_83856576196215707[32] = 0;
   out_83856576196215707[33] = 0;
   out_83856576196215707[34] = 0;
   out_83856576196215707[35] = 0;
   out_83856576196215707[36] = 0;
   out_83856576196215707[37] = 0;
   out_83856576196215707[38] = 0;
   out_83856576196215707[39] = 0;
   out_83856576196215707[40] = 0;
   out_83856576196215707[41] = 0;
   out_83856576196215707[42] = 0;
   out_83856576196215707[43] = 0;
   out_83856576196215707[44] = 0;
   out_83856576196215707[45] = 0;
   out_83856576196215707[46] = 0;
   out_83856576196215707[47] = 2*state[3]*state[9] - 2*state[4]*state[8] + 2*state[5]*state[7];
   out_83856576196215707[48] = -2*state[3]*state[8] - 2*state[4]*state[9] + 2*state[6]*state[7];
   out_83856576196215707[49] = 2*state[3]*state[7] - 2*state[5]*state[9] + 2*state[6]*state[8];
   out_83856576196215707[50] = 2*state[4]*state[7] + 2*state[5]*state[8] + 2*state[6]*state[9];
   out_83856576196215707[51] = 2*state[3]*state[5] + 2*state[4]*state[6];
   out_83856576196215707[52] = -2*state[3]*state[4] + 2*state[5]*state[6];
   out_83856576196215707[53] = pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2);
   out_83856576196215707[54] = 0;
   out_83856576196215707[55] = 0;
   out_83856576196215707[56] = 0;
   out_83856576196215707[57] = 0;
   out_83856576196215707[58] = 0;
   out_83856576196215707[59] = 0;
   out_83856576196215707[60] = 0;
   out_83856576196215707[61] = 0;
   out_83856576196215707[62] = 0;
   out_83856576196215707[63] = 0;
   out_83856576196215707[64] = 0;
   out_83856576196215707[65] = 0;
}
void h_14(double *state, double *unused, double *out_8735722694958550472) {
   out_8735722694958550472[0] = state[10];
   out_8735722694958550472[1] = state[11];
   out_8735722694958550472[2] = state[12];
}
void H_14(double *state, double *unused, double *out_3178586564223546385) {
   out_3178586564223546385[0] = 0;
   out_3178586564223546385[1] = 0;
   out_3178586564223546385[2] = 0;
   out_3178586564223546385[3] = 0;
   out_3178586564223546385[4] = 0;
   out_3178586564223546385[5] = 0;
   out_3178586564223546385[6] = 0;
   out_3178586564223546385[7] = 0;
   out_3178586564223546385[8] = 0;
   out_3178586564223546385[9] = 0;
   out_3178586564223546385[10] = 1;
   out_3178586564223546385[11] = 0;
   out_3178586564223546385[12] = 0;
   out_3178586564223546385[13] = 0;
   out_3178586564223546385[14] = 0;
   out_3178586564223546385[15] = 0;
   out_3178586564223546385[16] = 0;
   out_3178586564223546385[17] = 0;
   out_3178586564223546385[18] = 0;
   out_3178586564223546385[19] = 0;
   out_3178586564223546385[20] = 0;
   out_3178586564223546385[21] = 0;
   out_3178586564223546385[22] = 0;
   out_3178586564223546385[23] = 0;
   out_3178586564223546385[24] = 0;
   out_3178586564223546385[25] = 0;
   out_3178586564223546385[26] = 0;
   out_3178586564223546385[27] = 0;
   out_3178586564223546385[28] = 0;
   out_3178586564223546385[29] = 0;
   out_3178586564223546385[30] = 0;
   out_3178586564223546385[31] = 0;
   out_3178586564223546385[32] = 0;
   out_3178586564223546385[33] = 1;
   out_3178586564223546385[34] = 0;
   out_3178586564223546385[35] = 0;
   out_3178586564223546385[36] = 0;
   out_3178586564223546385[37] = 0;
   out_3178586564223546385[38] = 0;
   out_3178586564223546385[39] = 0;
   out_3178586564223546385[40] = 0;
   out_3178586564223546385[41] = 0;
   out_3178586564223546385[42] = 0;
   out_3178586564223546385[43] = 0;
   out_3178586564223546385[44] = 0;
   out_3178586564223546385[45] = 0;
   out_3178586564223546385[46] = 0;
   out_3178586564223546385[47] = 0;
   out_3178586564223546385[48] = 0;
   out_3178586564223546385[49] = 0;
   out_3178586564223546385[50] = 0;
   out_3178586564223546385[51] = 0;
   out_3178586564223546385[52] = 0;
   out_3178586564223546385[53] = 0;
   out_3178586564223546385[54] = 0;
   out_3178586564223546385[55] = 0;
   out_3178586564223546385[56] = 1;
   out_3178586564223546385[57] = 0;
   out_3178586564223546385[58] = 0;
   out_3178586564223546385[59] = 0;
   out_3178586564223546385[60] = 0;
   out_3178586564223546385[61] = 0;
   out_3178586564223546385[62] = 0;
   out_3178586564223546385[63] = 0;
   out_3178586564223546385[64] = 0;
   out_3178586564223546385[65] = 0;
}
void h_33(double *state, double *unused, double *out_9184153656412830582) {
   out_9184153656412830582[0] = state[16];
   out_9184153656412830582[1] = state[17];
   out_9184153656412830582[2] = state[18];
}
void H_33(double *state, double *unused, double *out_8992128094104130896) {
   out_8992128094104130896[0] = 0;
   out_8992128094104130896[1] = 0;
   out_8992128094104130896[2] = 0;
   out_8992128094104130896[3] = 0;
   out_8992128094104130896[4] = 0;
   out_8992128094104130896[5] = 0;
   out_8992128094104130896[6] = 0;
   out_8992128094104130896[7] = 0;
   out_8992128094104130896[8] = 0;
   out_8992128094104130896[9] = 0;
   out_8992128094104130896[10] = 0;
   out_8992128094104130896[11] = 0;
   out_8992128094104130896[12] = 0;
   out_8992128094104130896[13] = 0;
   out_8992128094104130896[14] = 0;
   out_8992128094104130896[15] = 0;
   out_8992128094104130896[16] = 1;
   out_8992128094104130896[17] = 0;
   out_8992128094104130896[18] = 0;
   out_8992128094104130896[19] = 0;
   out_8992128094104130896[20] = 0;
   out_8992128094104130896[21] = 0;
   out_8992128094104130896[22] = 0;
   out_8992128094104130896[23] = 0;
   out_8992128094104130896[24] = 0;
   out_8992128094104130896[25] = 0;
   out_8992128094104130896[26] = 0;
   out_8992128094104130896[27] = 0;
   out_8992128094104130896[28] = 0;
   out_8992128094104130896[29] = 0;
   out_8992128094104130896[30] = 0;
   out_8992128094104130896[31] = 0;
   out_8992128094104130896[32] = 0;
   out_8992128094104130896[33] = 0;
   out_8992128094104130896[34] = 0;
   out_8992128094104130896[35] = 0;
   out_8992128094104130896[36] = 0;
   out_8992128094104130896[37] = 0;
   out_8992128094104130896[38] = 0;
   out_8992128094104130896[39] = 1;
   out_8992128094104130896[40] = 0;
   out_8992128094104130896[41] = 0;
   out_8992128094104130896[42] = 0;
   out_8992128094104130896[43] = 0;
   out_8992128094104130896[44] = 0;
   out_8992128094104130896[45] = 0;
   out_8992128094104130896[46] = 0;
   out_8992128094104130896[47] = 0;
   out_8992128094104130896[48] = 0;
   out_8992128094104130896[49] = 0;
   out_8992128094104130896[50] = 0;
   out_8992128094104130896[51] = 0;
   out_8992128094104130896[52] = 0;
   out_8992128094104130896[53] = 0;
   out_8992128094104130896[54] = 0;
   out_8992128094104130896[55] = 0;
   out_8992128094104130896[56] = 0;
   out_8992128094104130896[57] = 0;
   out_8992128094104130896[58] = 0;
   out_8992128094104130896[59] = 0;
   out_8992128094104130896[60] = 0;
   out_8992128094104130896[61] = 0;
   out_8992128094104130896[62] = 1;
   out_8992128094104130896[63] = 0;
   out_8992128094104130896[64] = 0;
   out_8992128094104130896[65] = 0;
}
#include <eigen3/Eigen/Dense>
#include <iostream>

typedef Eigen::Matrix<double, DIM, DIM, Eigen::RowMajor> DDM;
typedef Eigen::Matrix<double, EDIM, EDIM, Eigen::RowMajor> EEM;
typedef Eigen::Matrix<double, DIM, EDIM, Eigen::RowMajor> DEM;

void predict(double *in_x, double *in_P, double *in_Q, double dt) {
  typedef Eigen::Matrix<double, MEDIM, MEDIM, Eigen::RowMajor> RRM;

  double nx[DIM] = {0};
  double in_F[EDIM*EDIM] = {0};

  // functions from sympy
  f_fun(in_x, dt, nx);
  F_fun(in_x, dt, in_F);


  EEM F(in_F);
  EEM P(in_P);
  EEM Q(in_Q);

  RRM F_main = F.topLeftCorner(MEDIM, MEDIM);
  P.topLeftCorner(MEDIM, MEDIM) = (F_main * P.topLeftCorner(MEDIM, MEDIM)) * F_main.transpose();
  P.topRightCorner(MEDIM, EDIM - MEDIM) = F_main * P.topRightCorner(MEDIM, EDIM - MEDIM);
  P.bottomLeftCorner(EDIM - MEDIM, MEDIM) = P.bottomLeftCorner(EDIM - MEDIM, MEDIM) * F_main.transpose();

  P = P + dt*Q;

  // copy out state
  memcpy(in_x, nx, DIM * sizeof(double));
  memcpy(in_P, P.data(), EDIM * EDIM * sizeof(double));
}

// note: extra_args dim only correct when null space projecting
// otherwise 1
template <int ZDIM, int EADIM, bool MAHA_TEST>
void update(double *in_x, double *in_P, Hfun h_fun, Hfun H_fun, Hfun Hea_fun, double *in_z, double *in_R, double *in_ea, double MAHA_THRESHOLD) {
  typedef Eigen::Matrix<double, ZDIM, ZDIM, Eigen::RowMajor> ZZM;
  typedef Eigen::Matrix<double, ZDIM, DIM, Eigen::RowMajor> ZDM;
  typedef Eigen::Matrix<double, Eigen::Dynamic, EDIM, Eigen::RowMajor> XEM;
  //typedef Eigen::Matrix<double, EDIM, ZDIM, Eigen::RowMajor> EZM;
  typedef Eigen::Matrix<double, Eigen::Dynamic, 1> X1M;
  typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> XXM;

  double in_hx[ZDIM] = {0};
  double in_H[ZDIM * DIM] = {0};
  double in_H_mod[EDIM * DIM] = {0};
  double delta_x[EDIM] = {0};
  double x_new[DIM] = {0};


  // state x, P
  Eigen::Matrix<double, ZDIM, 1> z(in_z);
  EEM P(in_P);
  ZZM pre_R(in_R);

  // functions from sympy
  h_fun(in_x, in_ea, in_hx);
  H_fun(in_x, in_ea, in_H);
  ZDM pre_H(in_H);

  // get y (y = z - hx)
  Eigen::Matrix<double, ZDIM, 1> pre_y(in_hx); pre_y = z - pre_y;
  X1M y; XXM H; XXM R;
  if (Hea_fun){
    typedef Eigen::Matrix<double, ZDIM, EADIM, Eigen::RowMajor> ZAM;
    double in_Hea[ZDIM * EADIM] = {0};
    Hea_fun(in_x, in_ea, in_Hea);
    ZAM Hea(in_Hea);
    XXM A = Hea.transpose().fullPivLu().kernel();


    y = A.transpose() * pre_y;
    H = A.transpose() * pre_H;
    R = A.transpose() * pre_R * A;
  } else {
    y = pre_y;
    H = pre_H;
    R = pre_R;
  }
  // get modified H
  H_mod_fun(in_x, in_H_mod);
  DEM H_mod(in_H_mod);
  XEM H_err = H * H_mod;

  // Do mahalobis distance test
  if (MAHA_TEST){
    XXM a = (H_err * P * H_err.transpose() + R).inverse();
    double maha_dist = y.transpose() * a * y;
    if (maha_dist > MAHA_THRESHOLD){
      R = 1.0e16 * R;
    }
  }

  // Outlier resilient weighting
  double weight = 1;//(1.5)/(1 + y.squaredNorm()/R.sum());

  // kalman gains and I_KH
  XXM S = ((H_err * P) * H_err.transpose()) + R/weight;
  XEM KT = S.fullPivLu().solve(H_err * P.transpose());
  //EZM K = KT.transpose(); TODO: WHY DOES THIS NOT COMPILE?
  //EZM K = S.fullPivLu().solve(H_err * P.transpose()).transpose();
  //std::cout << "Here is the matrix rot:\n" << K << std::endl;
  EEM I_KH = Eigen::Matrix<double, EDIM, EDIM>::Identity() - (KT.transpose() * H_err);

  // update state by injecting dx
  Eigen::Matrix<double, EDIM, 1> dx(delta_x);
  dx  = (KT.transpose() * y);
  memcpy(delta_x, dx.data(), EDIM * sizeof(double));
  err_fun(in_x, delta_x, x_new);
  Eigen::Matrix<double, DIM, 1> x(x_new);

  // update cov
  P = ((I_KH * P) * I_KH.transpose()) + ((KT.transpose() * R) * KT);

  // copy out state
  memcpy(in_x, x.data(), DIM * sizeof(double));
  memcpy(in_P, P.data(), EDIM * EDIM * sizeof(double));
  memcpy(in_z, y.data(), y.rows() * sizeof(double));
}




}
extern "C" {

void live_update_4(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_4, H_4, NULL, in_z, in_R, in_ea, MAHA_THRESH_4);
}
void live_update_9(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_9, H_9, NULL, in_z, in_R, in_ea, MAHA_THRESH_9);
}
void live_update_10(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_10, H_10, NULL, in_z, in_R, in_ea, MAHA_THRESH_10);
}
void live_update_12(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_12, H_12, NULL, in_z, in_R, in_ea, MAHA_THRESH_12);
}
void live_update_35(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_35, H_35, NULL, in_z, in_R, in_ea, MAHA_THRESH_35);
}
void live_update_32(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<4, 3, 0>(in_x, in_P, h_32, H_32, NULL, in_z, in_R, in_ea, MAHA_THRESH_32);
}
void live_update_13(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_13, H_13, NULL, in_z, in_R, in_ea, MAHA_THRESH_13);
}
void live_update_14(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_14, H_14, NULL, in_z, in_R, in_ea, MAHA_THRESH_14);
}
void live_update_33(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_33, H_33, NULL, in_z, in_R, in_ea, MAHA_THRESH_33);
}
void live_H(double *in_vec, double *out_7310749464307319056) {
  H(in_vec, out_7310749464307319056);
}
void live_err_fun(double *nom_x, double *delta_x, double *out_8236526131657428764) {
  err_fun(nom_x, delta_x, out_8236526131657428764);
}
void live_inv_err_fun(double *nom_x, double *true_x, double *out_4747477926419252764) {
  inv_err_fun(nom_x, true_x, out_4747477926419252764);
}
void live_H_mod_fun(double *state, double *out_341303559384211768) {
  H_mod_fun(state, out_341303559384211768);
}
void live_f_fun(double *state, double dt, double *out_4549525036970607503) {
  f_fun(state,  dt, out_4549525036970607503);
}
void live_F_fun(double *state, double dt, double *out_5133759507898990925) {
  F_fun(state,  dt, out_5133759507898990925);
}
void live_h_4(double *state, double *unused, double *out_6872450210111746980) {
  h_4(state, unused, out_6872450210111746980);
}
void live_H_4(double *state, double *unused, double *out_2937396917593955740) {
  H_4(state, unused, out_2937396917593955740);
}
void live_h_9(double *state, double *unused, double *out_8735722694958550472) {
  h_9(state, unused, out_8735722694958550472);
}
void live_H_9(double *state, double *unused, double *out_3178586564223546385) {
  H_9(state, unused, out_3178586564223546385);
}
void live_h_10(double *state, double *unused, double *out_4239705948005809237) {
  h_10(state, unused, out_4239705948005809237);
}
void live_H_10(double *state, double *unused, double *out_4956943889339789869) {
  H_10(state, unused, out_4956943889339789869);
}
void live_h_12(double *state, double *unused, double *out_3848117259651593996) {
  h_12(state, unused, out_3848117259651593996);
}
void live_H_12(double *state, double *unused, double *out_3558495942641549407) {
  H_12(state, unused, out_3558495942641549407);
}
void live_h_35(double *state, double *unused, double *out_854595621797169640) {
  h_35(state, unused, out_854595621797169640);
}
void live_H_35(double *state, double *unused, double *out_6304058974966563116) {
  H_35(state, unused, out_6304058974966563116);
}
void live_h_32(double *state, double *unused, double *out_2979708909891080243) {
  h_32(state, unused, out_2979708909891080243);
}
void live_H_32(double *state, double *unused, double *out_9087717139384980709) {
  H_32(state, unused, out_9087717139384980709);
}
void live_h_13(double *state, double *unused, double *out_7896661243212334910) {
  h_13(state, unused, out_7896661243212334910);
}
void live_H_13(double *state, double *unused, double *out_83856576196215707) {
  H_13(state, unused, out_83856576196215707);
}
void live_h_14(double *state, double *unused, double *out_8735722694958550472) {
  h_14(state, unused, out_8735722694958550472);
}
void live_H_14(double *state, double *unused, double *out_3178586564223546385) {
  H_14(state, unused, out_3178586564223546385);
}
void live_h_33(double *state, double *unused, double *out_9184153656412830582) {
  h_33(state, unused, out_9184153656412830582);
}
void live_H_33(double *state, double *unused, double *out_8992128094104130896) {
  H_33(state, unused, out_8992128094104130896);
}
void live_predict(double *in_x, double *in_P, double *in_Q, double dt) {
  predict(in_x, in_P, in_Q, dt);
}
}

const EKF live = {
  .name = "live",
  .kinds = { 4, 9, 10, 12, 35, 32, 13, 14, 33 },
  .feature_kinds = {  },
  .f_fun = live_f_fun,
  .F_fun = live_F_fun,
  .err_fun = live_err_fun,
  .inv_err_fun = live_inv_err_fun,
  .H_mod_fun = live_H_mod_fun,
  .predict = live_predict,
  .hs = {
    { 4, live_h_4 },
    { 9, live_h_9 },
    { 10, live_h_10 },
    { 12, live_h_12 },
    { 35, live_h_35 },
    { 32, live_h_32 },
    { 13, live_h_13 },
    { 14, live_h_14 },
    { 33, live_h_33 },
  },
  .Hs = {
    { 4, live_H_4 },
    { 9, live_H_9 },
    { 10, live_H_10 },
    { 12, live_H_12 },
    { 35, live_H_35 },
    { 32, live_H_32 },
    { 13, live_H_13 },
    { 14, live_H_14 },
    { 33, live_H_33 },
  },
  .updates = {
    { 4, live_update_4 },
    { 9, live_update_9 },
    { 10, live_update_10 },
    { 12, live_update_12 },
    { 35, live_update_35 },
    { 32, live_update_32 },
    { 13, live_update_13 },
    { 14, live_update_14 },
    { 33, live_update_33 },
  },
  .Hes = {
  },
  .sets = {
  },
  .extra_routines = {
    { "H", live_H },
  },
};

ekf_init(live);
